alphaSTART="wena";
alphaFINISH="weoa";

function setStartParam( t)
{	
	alphaSTART = "" + t.value;

}

function setFinishParam( t)
{	
	alphaFINISH = "" + t.value;

}


function convertParamToNumber(theParam)
{
	var alphaNum = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");		// associate a number with each alpha character
	var atoi = new Array();
	
	theParam="" + theParam;
	
	for(i=0; i<26; i++)
		atoi[ alphaNum[i] ] = i;
	
	index3 = theParam.charAt(0);
	index2 = theParam.charAt(1) ;
	index1 = theParam.charAt(2) ;
	index0 = theParam.charAt(3) ;
	
	num0 = atoi[ index0 ];
	num1 = atoi[ index1 ];
	num2 = atoi[ index2 ];
	num3 = atoi[ index3 ];
	
	theNumber = num0 + 26*( num1 + 26*(num2 + 26*num3));
	
	return theNumber;


}


function convertToParam(theNumber, theBASE)
{
	var alphaNum = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");		// associate a number with each alpha character

	index0 = Math.floor( theNumber/(theBASE*theBASE*theBASE) );
	remainder = theNumber % (theBASE*theBASE*theBASE);
	
	index1 = Math.floor( remainder/( theBASE*theBASE) );
	remainder = remainder % (theBASE*theBASE);
	
	index2 = Math.floor( remainder / theBASE);
	index3 = remainder % theBASE;
	
 	param = '"' + alphaNum[index0] + alphaNum[index1]  + alphaNum[index2] +  alphaNum[index3]+ '"';

	return param;

}


function ParamGCState()
{
	flashpoint();

	printf('# GetCameraState(param,...)');
	printf('# for all possible param permutations');
	printf('# "aaaa" to "zzzz" ');
	printf('# there are 26*26*26*26= 456976 POSSIBILITIES! ');
	printf('# so pick a subset !!!!!');
	printf('# use the entry boxes to select parameter range');
	printf('# i.e. "wena" to "weoa"');
	printf('# ');
	
	
	writeMenu('"GetCameraState"','"EXTRA"','"PARMGCState"');
	writeVariables();
  
 	 printf('<br>','#**** OPEN FILE ****');  
  	printf('outFile="/System/ZPGCS.txt"');
  	writeFileOpen();

	BASE = 26;
	
	START=convertParamToNumber(alphaSTART);
	FINISH=convertParamToNumber(alphaFINISH);
		
	printf('# ',alphaSTART," -> ", alphaFINISH );
	printf(' ');
		
	printf('count = 0');
	
	printf('GOAGAIN:');
	printf(' ');
	FINISH = FINISH - START;
	for( i = 0 ;i<= FINISH; i++)
	{
		printf( 'if count == ' , i );
		printf( 'param =',convertToParam(i+START,BASE) );
		printf('end')

	}

//	printf('Wait(100)');
	printf('status=GetCameraState(param,ivar)');
	printf('if status == 0')
	printf('WriteLine(fd,param,"[",status,"] ",ivar," GOOD") ');
	printf('end');
	printf('if status != 0')
	printf('WriteLine(fd,param,"[",status,"] ",ivar) ');
	printf('end');
	
	printf(' ');
	printf(' count = count + 1 ');
	printf('if count <= ',FINISH);
	printf('goto GOAGAIN');
	printf('end');

	writeFileClose();
	printf('exitscript');

}

